#include <iostream>

using namespace std;

char map[10][10];
int maxNum,n;

bool CanPut(int row, int col)
{
	int i;

	if (map[row][col] == 'X') return false;

    for (i = row - 1; i >= 0; --i)
    {
        if (map[i][col] == 'O') return false;
        if (map[i][col] == 'X') break;
    }
    
	for (i = col - 1; i >= 0; --i)
    {
        if (map[row][i] == 'O') return false;
        if (map[row][i] == 'X') break;
    }

    return true;
}

void Solve(int k,int curNum)
{
    int x,y;
    if(k==n*n)
    {
        if(curNum>maxNum)
        {
            maxNum=curNum;
            return;
        }
    }
    else
    {
        x=k/n;
        y=k%n;
        if((map[x][y]=='.')&&(CanPut(x,y)==true))
        {
            map[x][y]='O';
            Solve(k+1,curNum+1);
            map[x][y]='.';
        }

        Solve(k+1,curNum);
    }
}

int Weight(int x, int y) {
	int w = 0;
	for (int i = y+1; i < n; i ++)
	{
		if (map[x][i] == 'X') break;
		if (map[i][y] == '.') w++;
	}

	for (int i = y-1; i >= 0; i--)
	{
		if (map[x][i] == 'X') break;
		if (map[i][y] == '.') w++;
	}

	for (int i = x+1; i < n; i ++)
	{
		if (map[i][y] == 'X') break;
		if (map[i][y] == '.') w++;
	}	

	for (int i = x-1; i >= 0; i--)
	{
		if (map[i][y] == 'X') break;
		if (map[i][y] == '.') w++;
	}
	return w;
}

void MySolve(int k, int curNum)
{
	int x, y, m, minWeight;
	while(k<n*n) {
		x=k/n;
		y=k%n;

		if (CanPut(x,y) == true) {
			m = y;
			minWeight = Weight(x,y);
			if (y == n-1) {
				map[x][m] = 'O';
				cout<<x<<","<<m<<endl;
				maxNum++;
			}
			for (int i = y+1; i < n; i ++)
			{
				if (map[x][i] == 'X') {
					map[x][m] = 'O';
					cout<<x<<","<<m<<endl;
					maxNum++;
					break;
				}
				if (CanPut(x,i) && Weight(x,i) < minWeight) {
					m = i;					
					minWeight = Weight(x,i);
				}
				if (i == n -1) {
					map[x][m] = 'O';
					maxNum++;
					cout<<x<<","<<m<<endl;
				}
				k++;
			}
		}
		
		k++;
	}
}

int main()
{
    int i,j;
    while(cin>>n&&n!=0)
    {        
        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)
            {
                cin>>map[i][j];
            }
        }
        maxNum=0;
		MySolve(0,0);
        cout<<maxNum<<endl;
    }
    return 0;
}